﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.ProcessiingsWay;
using Traceability_Management.Read.Api.Application.CommandHandler.ProcessiingsWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessiingsAllController : ControllerBase
    {
        IMediator mediator;

        public ProcessiingsAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<ApiResult<int>> AddProcessiings(Processiings Processiings)
        {
            try
            {
                AddProcessiingsCommand AddProcessiingsCommand = new AddProcessiingsCommand()
                {
                    Processiings = Processiings
                };
                return await mediator.Send(AddProcessiingsCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Processiings>> FirstProcessiings([FromQuery] FirstProcessiongsCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateProcessiings(Processiings Processiings)
        {
            try
            {
                UpdateProcessiingsCommand UpdateProcessiingsCommand = new UpdateProcessiingsCommand() 
                {
                    Processiings = Processiings
                };
                return await mediator.Send(UpdateProcessiingsCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckProcessingInfoImgAll( [FromQuery] CheckProcessingInfoImgCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckProcessingMaterialImg1All([FromQuery] CheckProcessingMaterialImg1Command request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckProcessingMaterialImg2All([FromQuery] CheckProcessingMaterialImg2Command request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckProcessingMaterialImg3All([FromQuery] CheckProcessingMaterialImg3Command request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckProcessingMaterialImg4All([FromQuery] CheckProcessingMaterialImg4Command request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        
        [HttpGet]
        public async Task<ApiResult<int>> CheckProcessing_CompanyImgAll([FromQuery] CheckProcessing_CompanyImgCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
 
    }
}
